package org.lds.scheduled.job.common.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum TriggerRuleTypeEnum {
    FIX_RATE(1),
    CRON(2),
    ;

    /**
     * 类型
     */
    private Integer type;

    TriggerRuleTypeEnum(Integer type) {
        this.type = type;
    }

    private static final Map<Integer, TriggerRuleTypeEnum> LOOK_UP = new HashMap<>();
    static {
        TriggerRuleTypeEnum[] values = TriggerRuleTypeEnum.values();
        for (TriggerRuleTypeEnum value : values) {
            LOOK_UP.put(value.type, value);
        }
    }

    public static TriggerRuleTypeEnum getTriggerRule(Integer type) {
        return LOOK_UP.get(type);
    }
}
